package cn.iocoder.yudao.module.famous.doctor.dal.mysql.treatmentuser;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.famous.doctor.dal.dataobject.treatmentuser.TreatmentUserDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.famous.doctor.controller.admin.treatmentuser.vo.*;

import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;

/**
 * 就诊人 Mapper
 *
 * @author 档案
 */
@Mapper
public interface TreatmentUserMapper extends BaseMapperX<TreatmentUserDO> {

    default PageResult<TreatmentUserDO> selectPage(TreatmentUserPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<TreatmentUserDO>()
                .likeIfPresent(TreatmentUserDO::getName, reqVO.getName())
                .eqIfPresent(TreatmentUserDO::getSex, reqVO.getSex())
                .eqIfPresent(TreatmentUserDO::getIdentityCard, reqVO.getIdentityCard())
                .betweenIfPresent(TreatmentUserDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(TreatmentUserDO::getLabel, reqVO.getLabel())
                .eq(TreatmentUserDO::getCreator, getLoginUserId())
                .orderByDesc(TreatmentUserDO::getId));
    }

    default List<TreatmentUserDO> selectList(TreatmentUserExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<TreatmentUserDO>()
                .likeIfPresent(TreatmentUserDO::getName, reqVO.getName())
                .eqIfPresent(TreatmentUserDO::getSex, reqVO.getSex())
                .eqIfPresent(TreatmentUserDO::getIdentityCard, reqVO.getIdentityCard())
                .betweenIfPresent(TreatmentUserDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(TreatmentUserDO::getLabel, reqVO.getLabel())
                .eq(TreatmentUserDO::getCreator, getLoginUserId())
                .orderByDesc(TreatmentUserDO::getId));
    }

}
